home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Snippets / FindIcon / Copy_each_icon.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-21  |  995 b   |  40 lines  |  [TEXT/KAHL]

  1. #include "Copy_each_icon.h"
  2.  
  3. static pascal OSErr Copy_one_icon(
  4. /* --> */    ResType theType,
  5. /* <-> */    Handle *theIcon,
  6. /* --- */    void *yourDataPtr );
  7.  
  8. /*    ------------------------------------------------------------------
  9.     Copy_each_icon            This procedure makes copies of the icon
  10.                             handles in a suite, so that they will not
  11.     be resource handles and will not be purgeable.  Note that
  12.     if the originals are resources in a file that is in use by other
  13.     programs, then DetachResource would not be appropriate.
  14.     ------------------------------------------------------------------
  15. */
  16. OSErr Copy_each_icon(
  17. /* <-> */    Handle the_suite
  18. )
  19. {
  20.     return ForEachIconDo( the_suite, svAllAvailableData, Copy_one_icon, NULL );
  21. }
  22.  
  23. static pascal OSErr Copy_one_icon(
  24. /* --> */    ResType theType,
  25. /* <-> */    Handle *theIcon,
  26. /* --- */    void *yourDataPtr )
  27. {
  28.     OSErr    err;
  29.     
  30.     if (*theIcon != NULL)
  31.     {
  32.         LoadResource( *theIcon );
  33.         err = HandToHand( theIcon );
  34.         if (err != noErr)
  35.             *theIcon = NULL;
  36.     }
  37.     
  38.     return noErr;
  39. }
  40.